<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <style>
        body{
            background-color: coral;
        }
        form{
            margin-top: 8%;
        }
        input{
            font-size: 36px;
            width: 50%;
            margin-bottom: 20px;
        }
        p{
            text-align: center;
        }
        .submit{
            border: none;
            color: white;
            background-color: springgreen;
        }
    </style>
    <script src="/static/jq/jquery.min.js"></script>
</head>
<body>
    <form method="post">
        {% csrf_token %}
        <p>
            <input type="text" name="username" placeholder="用户名">
        </p>
        <p>
            <input id="email" type="text" name="email" placeholder="邮箱">
        </p>
        <p>
            <input type="password" name="password" placeholder="密码">
        </p>
        <p>
            <input type="password" name="d_password" placeholder="密码重复">
        </p>

        <p>
            <input class="submit" type="submit" value="提交">
        </p>
    </form>
    <p style="color: red" id="errormeg"></p>
    <script>
        $("#email").blur(
            function () {
                var em = $("#email").val();
                var url = "/user_valid/?email="+em;
                console.log(url);
                if(em){
                    $.ajax(
                        {
                            url:url,
                            type: "get",
                            data: "",
                            success: function (data) {
                                content = data["data"];
                                $("#errormeg").text(content)
                            },
                            error: function (error) {
                                console.log(error)
                            }
                        }
                    )
                }
            }
        )
    </script>
</body>
</html>